<?php
class Sizetitle extends AppModel {
	var $name = 'Sizetitle';	
	var $belongsTo = array(
			'Category'=>array('class'=>'Category',
			'foreignKey' => 'category_id')
		); 
	
	var $hasMany = array(
		'Sizevalue' => array(
			'className' => 'Sizevalue',
			'foreignKey' => 'sizetitle_id',
			'order' => 'id ASC',
			'dependent' => true		
		),
		'ProductSize'=>array(
		'class'=>'ProductSize',
		'foreignKey' => 'sizetitle_id'
		)
	);
	
		
	var $validate = array(
		'size_title' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Size label cannot be left empty',
			),
		)
	);
	function total_sizes($id = null){
		$this->recursive=-1;
		return $this->find('count',array('conditions'=>array('Sizetitle.category_id'=>$id)));
	}
	
}
?>